package com.bishe.bishe.dao.mapper;

import com.bishe.bishe.pojo.Orderdetail;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface OrderdetailMapper<Repository> extends Mapper<Orderdetail> {


    @Insert("insert into orderdetail(orderdetail_id,orderdetail_number,orderdetail_order_id,orderdetail_species_id) value(null,#{orderdetailNumber},#{orders.orderId},#{species.speciesId})")
    int insert(Orderdetail orderdetail);



    @Results({
            @Result(property = "orderdetailId",column = "orderdetail_id"),
            @Result(property = "orderdetailNumber",column = "orderdetail_number"),
            @Result(property = "orders",column = "orderdetail_order_id",one = @One(select = "com.bishe.bishe.dao.mapper.OrderMapper.finddetailById")),
            @Result(property = "species",column = "orderdetail_species_id",one = @One(select = "com.bishe.bishe.dao.mapper.SpeciesMapper.finddetailById")),
    })
    @Select("select * from orderdetail where orderdetail_order_id = #{orderId}")
    List<Orderdetail> findOrderdetail(@Param("orderId")Long orderId);

}
